package com.example.myapplication;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;

public class ZheView2 extends View {
    float x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0;
    float y1 = 0, y2 = 0, y3 = 0, y4 = 0, y5 = 0, y6 = 0;
    int width, height;

    public ZheView2(Context context, int width, int height) {
        super(context);
        this.width = width;
        this.height = height;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        setMeasuredDimension(this.height, this.width);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        Paint paint = new Paint();
        paint.setColor(Color.parseColor("#F44336"));

        Paint paintDot = new Paint();
        paintDot.setColor(Color.parseColor("#6200EE"));
        paintDot.setStrokeCap(Paint.Cap.ROUND);
        paintDot.setStrokeWidth(15);

        //画左边的
        //左眼
//        int center_x = this.width/4*3, center_y = this.height/2;
//        float facel_x = 0.0f, scale_y = 0.0f;

        // 铺满0-3/4, 以1/10的图像宽度参考坐标
//        int offset_x = (int) ((x3-x2) * 10 / this.width * this.width * 3 / 4);
//        canvas.drawPoint(this.width/2 - (x3-x2), this.height/2 - (y3-y2), paintDot);
        canvas.drawPoint(x2, y2, paintDot);

        //右眼
    }

    public void setLine(float[] floats) {
        this.x1 = floats[1];
        this.y1 = 640 - floats[0];
        this.x2 = floats[3];
        this.y2 = 640 - floats[2];
        this.x3 = floats[5];
        this.y3 = 640 - floats[4];

        invalidate();
    }
}
